function sectionChargeObj(selectID,tbodyID,chargeType,data){
	this.selectObj = document.getElementById(selectID);
	this.tbodyObj = document.getElementById(tbodyID);
	this.chargeType = chargeType;//收费类型
	this.count = 0;
	this.data = data;
	//this.data = "0,40,12.5;40,70,25.5;70,99999,30;" or "20"
	var selectedCode = null;

	this.initTbody = function(){
		if(this.selectObj.tagName == 'SELECT')
		{
			this.selectObj.setAttribute("onchange",this.selectOnChange);//one
			this.selectObj.setAttribute("_selectObj",this.tbodyObj);//tbody
			this.selectObj.setAttribute('_sectionChargeObj',this);//sectionChargeObj;
			this.selectObj.setAttribute('_tbodyObj',this.tbodyObj);
		}
		if(this.data != null)//修改初始化
		{
			selectedCode = this.selectObj.options[this.selectObj.selectedIndex].code;
			//alert(selectedCode)
			var objArray = this.data.split(";")
			if(selectedCode == "001")//单一计费
			{
				this.addSection5(this.data);
			}
			else if(selectedCode == "002" || selectedCode == "003")//阶梯计费,超额累进计费
			{
				this.addButton();
				if(chargeType == "002")//走表费用
				{
					if(objArray.length >0)
					{
						for(var i = 0 ; i < objArray.length-2; i++)
						{
							var objs = objArray[i].split(",");
							this.addSection1(objs[0],objs[1],objs[2]);
						}
					}
					var objs = objArray[objArray.length-2].split(",");
					this.addTail3(objs[0],objs[1],objs[2]);
				}
				else if(chargeType == "001")//常规
				{
					if(objArray.length >0)
					{
						for(var i = 0 ; i < objArray.length-2; i++)
						{
							var objs = objArray[i].split(",");
							this.addSection3(objs[0],objs[1],objs[2]);
						}
					}
					var objs = objArray[objArray.length-2].split(",");
					this.addTail1(objs[0],objs[1],objs[2]);
				}
			}
			else if(selectedCode == "004")//按段固定金额
			{
				this.addButton();
				if(chargeType == "002")//走表费用
				{
					if(objArray.length >0)
					{
						for(var i = 0 ; i < objArray.length-2; i++)
						{
							var objs = objArray[i].split(",");
							this.addSection2(objs[0],objs[1],objs[2]);
						}
					}
					var objs = objArray[objArray.length-2].split(",");
					this.addTail4(objs[0],objs[1],objs[2]);
				}
				else if(chargeType == "001")//常规
				{
					if(objArray.length >0)
					{
						for(var i = 0 ; i < objArray.length-2; i++)
						{
							var objs = objArray[i].split(",");
							this.addSection4(objs[0],objs[1],objs[2]);
						}
					}
					var objs = objArray[objArray.length-2].split(",");
					this.addTail2(objs[0],objs[1],objs[2]);
				}
			}
			//this.addSection1(0,10,12.5,'001');
			///this.addSection1(10,20,22.5,'001');
			///this.addSection1(30,40,32.5,'001');
			//this.addTail3(40,50);
		}
	};
	this.selectOnChange = function()
	{
		    selectedCode = this.options[this.selectedIndex].code;
			//empty(document.getElementById(tbodyID));
			empty(this._selectObj);
			//alert(tbodyID);
			//alert(this._selectObj);
			//alert(this._sectionChargeObj);

			if(selectedCode == "001")//单一计费
			{
				this._sectionChargeObj.addSection5();
			}
			else if(selectedCode == "002" || selectedCode == "003")//阶梯计费,超额累进计费
			{
				this._sectionChargeObj.addButton();
				if(chargeType == "002")//走表费用
				{
					this._sectionChargeObj.addSection1();
					this._sectionChargeObj.addTail3();
				}
				else if(chargeType == "001")//常规
				{
					this._sectionChargeObj.addSection3();
					this._sectionChargeObj.addTail1();
				}
			}
			else if(selectedCode == "004")//按段固定金额
			{
				this._sectionChargeObj.addButton();
				if(chargeType == "002")//走表费用
				{
					this._sectionChargeObj.addSection2();
					this._sectionChargeObj.addTail4();
				}
				else if(chargeType == "001")//常规
				{
					this._sectionChargeObj.addSection4();
					this._sectionChargeObj.addTail2();
				}
			}
	};
	this.addSection1 = function(minValue,maxValue,chargeValue){//走表阶梯与超额
		if(minValue == null)
		   minValue= 0;
		//if(maxValue == null)
		  // maxValue= 0;
		if(chargeValue == null)
		  chargeValue = "";
		//var td1 = new newTD1(minValue).buildTD();
		var td1 = new newTD11(minValue).buildTD();
		//var td2 = new newTD2(compare,maxValue,this.tbodyObj).buildTD();
		var td2 = new newTD21(maxValue,this.tbodyObj,this.chargeType,this).buildTD();
		var td3 = new newTD6().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addSection2 = function(minValue,maxValue,chargeValue){//走表固定金额
		if(minValue == null)
		   minValue= 0;
		//if(maxValue == null)
		  // maxValue= 0;
		if(chargeValue == null)
		  chargeValue = "";
		//var td1 = new newTD1(maxValue).buildTD();
		var td1 = new newTD11(minValue).buildTD();
		//var td2 = new newTD2(compare,null,this.tbodyObj).buildTD();
		var td2 = new newTD21(maxValue,this.tbodyObj,this.chargeType,this).buildTD();
		var td3 = new newTD3().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addSection3 = function(minValue,maxValue,chargeValue){//常规费用阶梯与超额
		if(minValue == null)
		   minValue= 0;
		//if(maxValue == null)
		  // maxValue= 0;
		if(chargeValue == null)
		  chargeValue = "";
		//var td1 = new newTD5(maxValue).buildTD();
		var td1 = new newTD51(minValue).buildTD();
		//var td2 = new newTD2(compare,null,this.tbodyObj).buildTD();
		var td2 = new newTD21(maxValue,this.tbodyObj,this.chargeType,this).buildTD();
		var td3 = new newTD6().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addSection4 = function(minValue,maxValue,chargeValue){//常规费用固定金额
		if(minValue == null)
		   minValue= 0;
		//if(maxValue == null)
		   //maxValue= 0;
		if(chargeValue == null)
		  chargeValue = "";
		//var td1 = new newTD5(maxValue).buildTD();
		var td1 = new newTD51(minValue).buildTD();
		//var td2 = new newTD2(compare,null,this.tbodyObj).buildTD();
		var td2 = new newTD21(maxValue,this.tbodyObj,this.chargeType,this).buildTD();
		var td3 = new newTD3().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addSection5 = function(chargeValue){//单一计费
		var td1 = new newTD6().buildTD();
		var td2 = new newTD4(chargeValue,this).buildTD();
		var td3 = new newTD7().buildTD();
		var td4 = new newTD8().buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addTail1 = function(minValue,maxValue,chargeValue){//常规费用阶梯与超额最后一个
		//var td1 = new newTD5(maxValue).buildTD();
		var td1 = new newTD51(minValue).buildTD();
		var td2 = new newTD8().buildTD();
		var td3 = new newTD6().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addTail2 = function(minValue,maxValue,chargeValue){//常规费用固定金额最后一个

		//var td1 = new newTD5(maxValue).buildTD();
		var td1 = new newTD51(minValue).buildTD();
		var td2 = new newTD8().buildTD();
		var td3 = new newTD3().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addTail3 = function(minValue,maxValue,chargeValue){//走表阶梯与超额最后一个
		//var td1 = new newTD1(minValue).buildTD();
		var td1 = new newTD11(minValue).buildTD();
		var td2 = new newTD8().buildTD();
		var td3 = new newTD6().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.addTail4 = function(minValue,maxValue,chargeValue){//走表固定金额最后一个
		//var td1 = new newTD1().buildTD();
		var td1 = new newTD11(minValue).buildTD();
		var td2 = new newTD8().buildTD();
		var td3 = new newTD3().buildTD();
		var td4 = new newTD4(chargeValue,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.getPreTR=function(){
		var trs = this.tbodyObj.getElementsByTagName("TR");
		if(trs == null){
			return null;
		}
		return trs[trs.length-3];
	};
	this.getCompare=function(){
		var pretr = this.getPreTR();
		if(pretr == null){
			return null;
		}else{
			var preSelect = pretr.getElementsByTagName("select");
			if(preSelect.length == 0)
				return null;
			else
			{
				//alert(pretr.innerHTML);
				return preSelect[0].options[preSelect[0].selectedIndex].value;
			}
		}
	};
	this.getMaxValue=function(){
		var pretr = this.getPreTR();
		if(pretr == null){
			return null;
		}else{
			var input = pretr.getElementsByTagName("input");
			//alert(pretr.innerHTML);
			if(input.length == 0)
				return null;
			else
			    return input[0].value;
		}
	};
	this.getChargeValue=function(){
		var pretr = this.getPreTR();
		if(pretr == null){
			return null;
		}else{
			var input = pretr.getElementsByTagName("input");
			if(input.length == 0)
				return null;
			else
				return input[0].value;
		}
	};
	this.deleteSection = function(type){
		//document.writeln(this.tbodyObj.innerHTML);
		var trs = this.tbodyObj.getElementsByTagName("TR");
		var   len   =   trs.length;
		if(len>7){
		  var currTr = trs[len-3];
		  var preTr = currTr.previousSibling;
		  var preinpValue = preTr.getElementsByTagName("INPUT")[0].value
		  //alert(preinpValue);
		  var curValue = currTr.getElementsByTagName("INPUT")[1].value;
          this.tbodyObj.removeChild(trs[len-3]);
		  //getlastinput
		  var inps = this.tbodyObj.getElementsByTagName("INPUT");
		  var inplength = inps.length;
		  inps[inplength-1].value= curValue;
		  //////////////////////////////////////////
		  var trss = this.tbodyObj.getElementsByTagName("TR");
		  var trslength = trss.length;
		  var lastfirstTd = trss[trslength-1].getElementsByTagName("TD")[0];
		  if(type == "001")
				lastfirstTd.innerHTML="范围面积：&nbsp;&nbsp;&nbsp;"+preinpValue+"&lt;面积≤";
		  else
				lastfirstTd.innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+preinpValue+"&lt;用量≤";
		  //////////////////////////////////////////
		}

	};
	this.addSection=function(num,maxnum){
		//alert(selectedCode);
		    if(selectedCode == "002" || selectedCode == "003")
			{
				if(chargeType == "002")
				{
					this.addSection1(num,"",maxnum);
				}
				else if(chargeType == "001")
				{
					this.addSection3(num,"",maxnum);
				}
			}else if(selectedCode == "004")
			{
				if(chargeType == "002")
				{
					this.addSection2(num,"",maxnum);
				}
				else if(chargeType == "001")
				{
					this.addSection4(num,"",maxnum);
				}
			}
			//alert("over");

			var trs = this.tbodyObj.getElementsByTagName("TR");
			var len = trs.length;
			trs[len-3].swapNode(trs[len-2]);//交换最后两个位置
			//document.write(this.tbodyObj.innerHTML);

	};
	this.addButton= function(){
		var td1 = new newTD7().buildTD();
		//var td2 = new newButton().buildTD();
		var td2 = new newButtonTD(this).buildTD();
		var td3 = new newTD7().buildTD();
		var td4 = new newTD8().buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.getResult=function(){
		var str = "0,";
		var inputObj = this.tbodyObj.getElementsByTagName('INPUT');
		if(inputObj.length == 1){
			str = inputObj[0].value;
		}else
		{
			for(var i = 0 ; i < inputObj.length; i++)
			{
				if(i == 0)
				   str= str+inputObj[i].value+","+inputObj[i+1].value+";";
				if(i>1 && i % 2 == 0 && i < inputObj.length-1)
				   str = str+inputObj[i-2].value+","+inputObj[i].value+","+inputObj[i+1].value+";";
				if(i == inputObj.length-1)
				   str = str+inputObj[i-2].value+",99999,"+inputObj[i].value+";";
			}

		}
		return str;
	}
}
function newTD1(num){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.vAlign="top";
		mytd.className="aux_intable_td1";
		if(num==null)
			num=0;
		mytd.innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+num+"&lt;用量";
		return mytd;
	}
}
function newTD11(num){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.vAlign="middle";
		mytd.className="aux_intable_td1";
		if(num==null)
			num=0;
		mytd.innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+num+"&lt;用量≤";
		return mytd;
	}
}
function newTD2(flag,num,tbodyObj){
	this._tbodyObj = tbodyObj;
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td2";
		mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.align="left";
		var tr = mytable.insertRow();
		var td0=tr.insertCell(0);td0.width="6%";
		var myselect = document.createElement('select');myselect.name="select6";myselect.setAttribute("_td",mytd)
		myselect.onchange = function(){
			var next_tr =this._td.parentNode.nextSibling;
			flag="";
			if(next_tr != null)
			{
				var tds = next_tr.getElementsByTagName("TD");
				for(var i = 0; i<this.options.length;i++)//目前只有两个选择项
				{
						if(this.options[0].selected)
						{
							flag = this.options[1].text;
						}
						else
							flag = this.options[0].text;
				}
				tds[0].innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+num+flag+"用量";
			}
		}
		var optionText = new Array();
        optionText[0] = "≤";
        optionText[1] = "＜";
		var optionValue = new Array();
        optionValue[0] = "1";
        optionValue[1] = "0";
		for(var i=0;i<2;i++)
        {
               myselect.options[i] = new Option(optionText[i], optionValue[i]);
        }
		if(flag == "0")
		{
			myselect.options[1].selected=true;
		}
		td0.appendChild(myselect);
		var td1=tr.insertCell(1);td1.align="left";td1.className="aux_intable_require";
		if(num== null)
			num="";
		myinput = document.createElement('input');
		myinput.type="text";myinput.name="name1";;myinput.className="required";myinput.value=num;myinput.size="16";
		myinput.setAttribute("_tbodyObj",this._tbodyObj);
		myinput.setAttribute("_td",mytd);
		myinput.setAttribute("_select",myselect);
		myinput.onblur=  function(){
			var next_tr =this._td.parentNode.nextSibling;
			if(next_tr != null)
			{
				var tds = next_tr.getElementsByTagName("TD");
				//alert(next_tr.innerHTML);
				//alert(tds[0].innerHTML);
				tds[0].innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+this.value+this._flag+"用量";
			}
		}
		td1.appendChild(myinput);
		mytd.appendChild(mytable);
		/*if(num==null)
			num="";
		var tep = "<table border='0' align='left' cellpadding='0' cellspacing='0'><tr><td width='6%'><select name='select6'>";
		if(flag=="0")
			tep= tep+"<option  value='1'>≤</option><option selected value='0'>＜</option>";
		else
		    tep= tep+"<option selected value='1'>≤</option><option value='0'>＜</option>";
		mytd.innerHTML= tep+"</select></td><td align='left' class='aux_intable_require'><input name='name1' type='text' class='required' size='16' value='"+num+"'></td></tr></table>";
		*/
		return mytd;
	}
}
function newTD21(num,tbodyObj,type,sectionChargeObj){
	this._tbodyObj = tbodyObj;
	this._sectionChargeObj = sectionChargeObj;
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td2";
		mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.align="left";
		var tr = mytable.insertRow();
		var td0=tr.insertCell(0);td0.width="1%";
		td0.innerText = "";
		var td1=tr.insertCell(1);td1.align="left";td1.className="aux_intable_require";
		if(num== null)
			num="";
		myinput = document.createElement('input');
		var count = this._sectionChargeObj.count++;
		myinput.type="text";myinput.name="name"+count;myinput.className="required float-range-0-99999";myinput.value=num;myinput.size="16";
		myinput.setAttribute("_tbodyObj",this._tbodyObj);
		myinput.setAttribute("_td",mytd);
		myinput.onblur=  function(){
			var next_tr =this._td.parentNode.nextSibling;
			var pre_tr = this._td.parentNode.previousSibling;
			var pinputs = pre_tr.getElementsByTagName("INPUT");
			if(pinputs != null && pinputs.length == 2)
			{
				//alert(pinputs[0].value);
				var temp = parseFloat(pinputs[0].value)+1;
				this.setAttribute("className","required float-range-"+temp+"-99999");
			}
			if(next_tr != null)
			{
				var tds = next_tr.getElementsByTagName("TD");
				if(isNaN(parseFloat(this.value)))
					return false;
				if(type == "001")
					tds[0].innerHTML="范围面积：&nbsp;&nbsp;&nbsp;"+this.value+"&lt;面积≤";
				else
				    tds[0].innerHTML="用量范围：&nbsp;&nbsp;&nbsp;"+this.value+"&lt;用量≤";

			}
		}
		td1.appendChild(myinput);
		mytd.appendChild(mytable);
		return mytd;
	}
}

function newTD3(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td1";
		mytd.innerHTML="金额：";
		return mytd;
	}
}
function newTD4(chargeValue,sectionChargeObj){
	this._sectionChargeObj = sectionChargeObj;
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_require";
		if(chargeValue==null)
			chargeValue="";
		myinput = document.createElement('input');
		var count = this._sectionChargeObj.count++;
		myinput.type="text";myinput.name="name"+count;myinput.className="required float-range-0-99999";myinput.value=chargeValue;myinput.size="16";myinput.align="right";myinput.setAttribute("afterInsert","tip"+count);
		myinputtext = document.createTextNode("元");
		myspan = document.createElement('span');
		myspan.id = "tip"+count;
		mytd.appendChild(myinput);
		mytd.appendChild(myinputtext);
		mytd.appendChild(myspan);
		//mytd.innerHTML="<input name='name2' type='text' class='required' value='"+num+"' size='16'  align='right'>元";
		return mytd;
	}
}
function newTD5(num){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.vAlign="top";
		mytd.className="aux_intable_td1";
		if(num==null)
			num=0;
		mytd.innerHTML="范围面积：&nbsp;&nbsp;&nbsp;"+num+"&lt;面积";
		return mytd;
	}
}
function newTD51(num){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.vAlign="middle";
		mytd.className="aux_intable_td1";
		if(num==null)
			num=0;
		mytd.innerHTML="范围面积：&nbsp;&nbsp;&nbsp;"+num+"&lt;面积≤";
		return mytd;
	}
}
function newTD6(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td1";
		mytd.innerHTML="单价：";
		return mytd;
	}
}
function newTD7(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td1";
		mytd.innerHTML="&nbsp;";
		return mytd;
	}
}
function newTD8(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td2";
		mytd.innerHTML="&nbsp;";
		return mytd;
	}
}

function newTR1(tdObject1,tdObject2,tdObject3,tdObject4){
	this.tdObject1 = tdObject1;
	this.tdObject2 = tdObject2;
	this.tdObject3 = tdObject3;
	this.tdObject4 = tdObject4;
	this.buildTR = function(){
		var mytr = document.createElement('tr');
		mytr.appendChild(this.tdObject1);
		mytr.appendChild(this.tdObject2);
		mytr.appendChild(this.tdObject3);
		mytr.appendChild(this.tdObject4);
		return mytr;
	}
}
function newButton(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td2";
		mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		var tr = mytable.insertRow();
		var td0=tr.insertCell(0);td0.innerHTML="&nbsp;";
		var td1=tr.insertCell(1);
		mytd.innerHTML="<table border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td><td ><table border='0' cellpadding='0' cellspacing='0' ><tr><td class='buttonOffLeft' id='btn1_41'></td><td class='buttonOffMiddle' id='btn1_42' onMouseOver='btn_change_over(4)' onMouseOut='btn_change_out(4)' onblur='btn_change(4)'><img src='images/ico_zengjia.gif' border='0' align='absbottom'/>增加分段 </td><td class='buttonOffRight' id='btn1_43'></td></tr></table></td><td width='4'>&nbsp;</td><td ><table border='0' cellpadding='0' cellspacing='0' ><tr><td class='buttonOffLeft' id='btn1_11'></td><td class='buttonOffMiddle' id='btn1_12' onMouseOver='btn_change_over(1)' onMouseOut='btn_change_out(1)' onblur='btn_change(1)'><img src='images/ico_cancel.gif' border='0' align='absbottom'/>删除分段 </td><td class='buttonOffRight' id='btn1_13'></td></tr></table></td></tr></table>";
		return mytd;
	}

}
function newTable1(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	this.buildTABLE = function(){
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.setAttribute("_sectionCharge", this._sectionChargeObj);
		mytable.onclick = function(){
			var tempinp = this._sectionCharge.tbodyObj.getElementsByTagName('INPUT');
			//alert("length:"+tempinp.length);
			var inp = tempinp[tempinp.length-3];
			//alert(inp.value);
			var myvalue=inp.value;
			var maxnum = tempinp[tempinp.length-1].value;
			tempinp[tempinp.length-1].value="";
			this._sectionCharge.addSection(myvalue,maxnum);
		};
		var tr = mytable.insertRow();
		var td0 = tr.insertCell(0);
		td0.className ='buttonOffLeft';
		td0.id = "btn1_41";
		var td1 = tr.insertCell(1);
		td1.className = "buttonOffMiddle";
		td1.id="btn1_42";
		td1.onMouseOver="btn_change_over(4)";
		td1.onMouseOut="btn_change_out(4)";
		td1.onblur="btn_change(4)";
		td1.innerHTML = "<img src='images/ico_zengjia.gif' border='0' align='absbottom'/>增加分段"
		var td2 = tr.insertCell(2); td2.className = "buttonOffRight";td2.id="btn1_43";
		return mytable;
	}
}
function newTable2(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	this.buildTABLE = function(){
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.setAttribute("_sectionCharge", this._sectionChargeObj);
		mytable.onclick = function(){
			//alert(this._sectionCharge.chargeType);
			this._sectionCharge.deleteSection(this._sectionCharge.chargeType);
		};
		var tr = mytable.insertRow();
		var td0 = tr.insertCell(0); td0.className ='buttonOffLeft'; td0.id = "btn1_11";
		var td1 = tr.insertCell(1); td1.className = "buttonOffMiddle";td1.id ="btn1_12";td1.onMouseOver="btn_change_over(1)"; td1.onMouseOut="btn_change_out(1)"; td1.onblur="btn_change(1)";
		td1.innerHTML = "<img src='images/ico_cancel.gif' border='0' align='absbottom'/>删除分段 "
		var td2 = tr.insertCell(2); td2.className = "buttonOffRight";td2.id="btn1_13";
		return mytable;
	}
}
function newTable3(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	//alert(sectionChargeObj);
	this.buildTABLE = function(){
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		var mytr1 = mytable.insertRow();
		var mytd1= mytr1.insertCell(0);
		mytd1.innerHTML="&nbsp;";
		var mytd2= mytr1.insertCell(1);
		mytd2.appendChild(new newTable1(this._sectionChargeObj).buildTABLE());
		var mytd3 = mytr1.insertCell(2);
		mytd3.innerHTML="&nbsp;";
		var mytd4 = mytr1.insertCell(3);
		mytd4.appendChild(new newTable2(this._sectionChargeObj).buildTABLE());
		return mytable;
	}
}
function newButtonTD(sectionChargeObj){
	this._sectionChargeObj = sectionChargeObj;
	//alert(sectionChargeObj);
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td2";
		mytd.appendChild(new newTable3(this._sectionChargeObj).buildTABLE());
		return mytd;
	}
}
function remove(elem){
  if (elem)
	  elem.parentNode.removeChild(elem);
}
function empty(elem){
 while (elem.firstChild)
  remove(elem.firstChild);
}
function setTail(td,input)
{
	td.innerHTML = "用量范围：&nbsp;&nbsp;&nbsp;"+input.value+"&lt;用量";
}
function showSelectValue(selectName,hiddenName)
{
	var len = $(selectName).options.length;
		for(var i = 0 ; i < len ; i++)
		{
			var code = $(selectName).options[i].code;
			if($(hiddenName).value == code)
			{
				$(selectName).options[i].selected = true;
			}
		}
}
function showRadioCheckedValue(radioName,hiddenName)
{
	var radios = document.getElementsByName(radioName);
	for(var i = 0 ; i < radios.length ; i++)
	{
		if($(hiddenName).value == radios[i].value)
		{
		     radios[i].checked = true;
			 break;
		}
	}
}
function showBoxCheckedValue(boxName){
	if($(boxName).value == "1")
		$(boxName).checked = true;
}
function setRadioValueToHidden(radioName,hiddenName,rate)
{
	var radios = document.getElementsByName(radioName);
	for(var i = 0 ; i < radios.length ; i++)
	{
		if(radios[i].checked)
		{
		     $(hiddenName).value = radios[i].value;
			 break;
		}
	}
}
function setSelectCodeToHidden(selectName,hiddenName)
{
	$(hiddenName).value =  $(selectName).options[$(selectName).selectedIndex].code;
}
function setCheckBoxValue(boxName)
{
	if($(boxName).checked){
		$(boxName).value = "1";
	}else{
		$(boxName).value = "0";
	}
}
function setRadioRelation(thiz, relationName){
	if(thiz.value == "0" ){
		$(relationName).value = "";
		Validation.changeElmValidate(relationName,"inputtext");
		$(relationName).setAttribute("readOnly",true);
	}else{
		Validation.changeElmValidate(relationName,"required float-right integer-decimal-range-8-2");
		$(relationName).setAttribute("readOnly",false);
	}
}
function mydisplay(ID,hiddenorshow,tdId,innerId,boxName){
	var getID=ID.split(",");
	var IDlist=new Array();
	if(hiddenorshow=="show")
	{
		for(var j=0;j<getID.length;j++)
		{
			IDlist[j]=getID[j];
			document.getElementById(IDlist[j]).style.display="";
		}
		$(tdId).setAttribute("className","aux_intable_require");
	}
	else if(hiddenorshow=="hidden")
	{
		for(var j=0;j<getID.length;j++)
		{
			IDlist[j]=getID[j];
			document.getElementById(IDlist[j]).style.display="none";
		}
		$(innerId).value="";
		$(boxName).checked = false;
		$(tdId).setAttribute("className","aux_intable_td2");
	}
}
